package com.wxzz.elearing.user.api.app;

import com.alibaba.fastjson.JSONObject;
import com.wxzz.elearing.user.dto.AdminGuidelineDto;
import com.wxzz.elearing.user.dto.WorkGuidelineDto;
import com.wxzz.elearing.user.entity.AdminWorkGuideline;
import com.wxzz.elearing.user.service.IAdminWorkGuidelineService;
import com.wxzz.elearing.user.vo.AdminWorkGuidelineVo;
import com.wxzz.elearning.common.vo.JgPageVo;
import com.wxzz.elearning.common.vo.ReturnVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/wx-work-guideline")
@Api(tags = "工作指引(小程序)")
public class WxworkGuidelineController {

    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    @Autowired
    private IAdminWorkGuidelineService iAdminWorkGuidelineService;

//    @ApiOperation(value = "添加工作指引", notes = "添加工作指引", httpMethod = "POST", tags = "后台")
//    @RequestMapping(value = "addAdminGuideline", method = RequestMethod.POST)
//    public ReturnVO addAdminGuideline(@RequestHeader String token,  @RequestBody AdminWorkGuideline adminWorkGuideline) {
//        JSONObject jsonObject = JSONObject.parseObject(redisTemplate.opsForValue().get(token));
//        adminWorkGuideline.setEnterpriseId(jsonObject.getInteger("enterpriseId"));
//        adminWorkGuideline.setAdminUserId(jsonObject.getLong("id"));
//        return iAdminWorkGuidelineService.addAdminGuideline(adminWorkGuideline);
//    }

    @ApiOperation(value = "工作指引列表", notes = "工作指引列表", httpMethod = "POST", tags = "小程序")
    @RequestMapping(value = "adminGuidelineList", method = RequestMethod.POST)
    public ReturnVO<JgPageVo<List<AdminWorkGuidelineVo>>> adminGuidelineList(@RequestHeader String token, @RequestBody AdminGuidelineDto adminGuidelineDto) {
        JSONObject jsonObject = JSONObject.parseObject(redisTemplate.opsForValue().get(token));
        adminGuidelineDto.setEnterpriseId(jsonObject.getInteger("enterpriseId"));
        return iAdminWorkGuidelineService.getAdminGuidelineList(adminGuidelineDto);
    }

//    @ApiOperation(value = "删除工作指引", notes = "删除工作指引", httpMethod = "POST", tags = "后台")
//    @RequestMapping(value = "deleteWorkGuide", method = RequestMethod.POST)
//    public ReturnVO deleteWorkGuide(@RequestHeader String token, @RequestBody WorkGuidelineDto workGuidelineDto) {
////        JSONObject jsonObject = JSONObject.parseObject(redisTemplate.opsForValue().get(token));
////        adminWorkGuideline.setCreatePerson(jsonObject.getLong("enterpriseId"));
////        adminWorkGuideline.setCreatePerson(jsonObject.getString("nickname"));
//        return iAdminWorkGuidelineService.deleteWorkGuide(workGuidelineDto);
//    }

}
